home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacWorld 1997 September
/
Macworld (1997-09).dmg
/
Shareware World
/
Utilities
/
Text Processing
/
Alpha
/
Help
/
Debugging
< prev
next >
Wrap
Text File
|
1994-08-03
|
2KB
|
76 lines
5.0 introduces the Tcl function-tracing command 'traceFunc'. traceFunc
allows you to trace a specfic function whenever it is called, sending the
output to another window. The indented trace of the function includes all
parameters, each argument enclosed within single quotes, as well as the
function result.
The syntax of the function is:
traceFunc on <funcName> <winName>
traceFunc off
traceFunc status
For example, if I want to trace the proc 'nextFunc' (defined in
procs.tcl), the following might be a log of my activity at the Tcl shell:
Welcome to Alpha's Tcl shell.
Alpha> traceFunc on nextFunc traceWin
Alpha> traceFunc status
Func-tracing on, func: nextFunc, win: traceWin
Alpha>
Now I create a new window, "dirty" it so that I can get a save dialog,
and save it as 'traceWin'. Note that tracing is only sent to open
windows, so I must leave 'traceWin' open.
Then I open any random non-C file (because I want the function to fail), go
to the beginning of the file, and type escape-x 'nextFunc'. The output
should look something like the following:
nextFunc
searchFunc '1'
getPos
OK: 38530
select '38530'
OK:
saveVars
OK:
if '(1==1)' '
nextLine
' 'else' '
previousLine
'
nextLine
OK:
OK:
getPos
OK: 38573
set 'pos' '38573'
OK: 38573
setVar 'regExpr' '1'
OK:
setVar 'forward' '1'
OK:
setVar 'ignoreCase' '1'
OK:
search '^[^ \t\(#\r/@].*\(.*\)$' '38573'
ERROR: Search unsuccessful
ERROR: Search unsuccessful
ERROR: Search unsuccessful
The trace output shows that the problem was an unsuccessful search. In
this case, a dialog informed us of this fact anyway, but many Alpha
routines are not as friendly when it comes to error messages.
Another way to debug Tcl routines is to insert statements that print
values to another window. For example, one could use the following
routine:
proc out args {
insertText -w "*tcl shell*" $args
}